var information={
		 currentPage:1,	
		  totalPage:1 
};
$(function(){
	getAllFiniCom(null);
	initTaskDis();
	requestSource();
	requestSort();
	requestClassification();
	//requestSourceSel();
	alert();	 $(document).on("click",".detail",function(){
		  var id= $(this).attr("data-id");
			var menuId=$("#menu-container").attr("menu-id");
			alert();
//			window.location.href = '../information/evaluationDetailInfo.jsp?menuId='+menuId+'&detailId=' + id;
	  })
	 //分页，首页
	  $("#headPage").click(function(){
		information.currentPage=1;
	  	$("#totalPage").html(information.currentPage+"/"+information.totalPage);
	  	getAllFiniCom(information);
	  })
	  

	  //分页，尾页
	  $("#endPage").click(function(){
	  	$("#totalPage").html(information.totalPage+"/"+information.totalPage);
	  	information.currentPage=information.totalPage;
	  	getAllFiniCom(information);
	  })
	  //分页，上一页
	  $("#prevPage").click(function(){
	  	if(information.currentPage<=1)
	  	{
	  		information.currentPage=1;
	  	}
	  	else
	  	{
	  		information.currentPage=information.currentPage-1;
	  		$("#totalPage").html(information.currentPage+"/"+information.totalPage);  
	  		getAllFiniCom(information);
	  	}

	 })
	 
	  //分页，下一页
	   $("#nextPage").click(function(){
	  	
	  	if(information.currentPage>=information.totalPage)
	  	{
	  		information.currentPage=information.currentPage;
	  	}
	  	else
	  	{
	  		information.currentPage=information.currentPage+1;
	  		$("#totalPage").html(information.currentPage+"/"+information.totalPage);
	  		getAllFiniCom(information);
	  	}
	  	
	  })
});

//向后台请求分级信息
function requestClassification()
{	
	var url="getAllInformationClassification.do";//分级地址
	var data={};
	var object={};
	data=YuXi.util.get(url,"null",function(data){
		object=data.object;
		//用data循环添加分口信息
		for(var i=0;i<object.length;i++)
		{
			var html="<option  value="+object[i].id+" >"+object[i].name+"</option>";
			$(".pes").append(html);
		}
	},function(){
		
	});//请求数据
	
}
//向后台请求分类信息
/*function requestSort()
{	//数据模拟

	
	
	var url="getAllInfomationSort.do";//分类地址
	var data={};
	var object={};
	data=YuXi.util.get(url,"null",function(data){
		object=data.object;
		//用data循环添加分类信息
		for(var i=0;i<object.lengths;i++)
		{
			var html="<option  value="+object[i].id+" >"+object[i].name+"</option>";
			$(".sort").append(html);
		}
	},function(){
		
	});//请求数据
	
}*/
//向后台请求渠道信息
function requestSource()
{	
	
	var url="getAllInfomationSource.do";//渠道地址
	var data={};
	var object={};
	data=YuXi.util.get(url,"null",function(data){
		object=data.object;
		for(var i=0;i<object.length;i++)
		{
			var html= "<label class='checkbox-inline'><input type='checkbox'  class='check' data-na="+object[i].name+" value="+object[i].id+" name='source'><span>"+object[i].name+"</span></label>";
			$(".reSearchSource ").append(html);
		}
		
	},function(){});//请求数据
	
}

/*获取所有已点评的信息*/
function getAllFiniCom(data){
	$("tbody").html("");
	 YuXi.util.get("getRate.do",data,function(data){
		 information.currentPage=data.currentPage;
		 information.totalPage=data.totalPage;
		 $("#totalPage").html(information.currentPage+"/"+information.totalPage);
		 var object=data.list;
		for(var i=0;i<object.length;i++){			
			var time=YuXi.getTime.get(object[i].createTime);
			var html='<tr>'+
				'<td>'+object[i].id+'</td>'+
				'<td>'+object[i].informationId+'</td>'+
	        	'<td>'+object[i].userName+'</td>'+
	        	'<td>'+object[i].content+'</td>'+
	        	'<td>'+time+'</td>'+
	        	'<td>'+object[i].borwse+'</td>'+
	            '<td>'+
	                '<span class="btn btn-xs btn-primary detail" data-id="'+object[i].informationId+'">查看详情</span>'+
	            '</td>'+
	        '</tr>';
			$("tbody").append(html);
		}
		YuXi.graded.get();
		
	});
}


function initTaskDis(){
	 YuXi.util.get("getAllInformationClassification.do",null,function(data){
		 if(data.status){
			 var obj=data.object;
			 for(var i=0;i<obj.length;i++){
				 $(".reSearchpes").append("<option value='"+obj[i].id+"' >"+obj[i].name+"</option>");
			 }
			 
		 }
	 });
	 
	 YuXi.util.get("getAllInfomationSource.do",null,function(data){
		 if(data.status){
			 var obj=data.object;
			 for(var i=0;i<obj.length;i++){
				 $(".reSearchSource").append("<option value='"+obj[i].id+"' >"+obj[i].name+"</option>");
			 }
			 
		 }
	 });
	 
	 YuXi.util.get("getAllInformationPort.do",null,function(data){
		 if(data.status){
			 var obj=data.object;
			 for(var i=0;i<obj.length;i++){
				 $(".task-port").append("<option value='"+obj[i].id+"' >"+obj[i].portName+"</option>");
			 }
			 
		 }
	 });
	
}
$("#firstSearch").click(function(){
	firstSearch();
});
//简介，分级，渠道，状态，时间（今天,一周...）查找
function firstSearch()
{
	information={};
		information.key = $("#profile").val(); //简介
		if($("#profile").val()=="请输入简介关键字")
		{
			information.key="";
		}
		information.informationLv = $(".reSearchpes option:selected").val() //分级
		information.informationSort = $(".reSearchsort option:selected").val() //分类
		information.informationSource = $(".reSearchSource option:selected").val() //来源渠道
		var curFlowText = $(".reSearchFlow option:selected").val();
		curFlowText == null ? "" : information.curFLow = curFlowText; //当前流程
		information.safetyPortId=$(".rePort option:selected").val();//分口
		information.informationJudge=$(".repingjia option:selected").val();//评价
		var inputNameFlag=$("#requestName").val();//参与人
		if(inputNameFlag=="请输入参与人姓名或警号")
		{
			information.intputName="";
		}
		else
		{ 
			var flag=/^[(-?\d+\.\d+)|(-?\d+)|(-?\.\d+)]+$/.test(inputNameFlag + '');
			
			if(!flag)
			{
				information.intputName=inputNameFlag;
			}
			else
			{
				information.intputNumber=inputNameFlag;
			}
		}
		var finishNameFlag=$("#refinishName").val();//完成人
		
		information.structure=$(".reDepartment option:selected").val();//部门
		information.qualityId=$(".reinputDian option:selected").val();//录入点评
		information.completeId=$(".refinishDian option:selected").val();//完成点评
		var array=[];
		var starTime="";	
		var endTime="";
		starTime=$("#submitstarTime").val();//提交起始时间
		endTime=$("#submitendTime").val();//提交结束时间
		array = YuXi.timestamp.get(starTime,endTime, null);
		if(array[0]!=null)
		information.startTimestamp = array[0];
		if(array[1]!=null)
		information.endTimestamp = array[1];
	

	
		

		starTime=$("#starTime").val();//建立起始时间
		endTime=$("#endTime").val();//建立结束时间
		array = YuXi.timestamp.get(starTime,endTime, null);
		if(array[0]!=null)
		information.startTimestamp = array[0];
		if(array[1]!=null)
		information.endTimestamp = array[1];
		information.flowId=2;
		information.currentPage=1;

	
	getAllFiniCom(information);
	
	
}

function requestSort(){	
	var url="getAllInfomationSort.do";//分类地址
	var data={};
	var object={};
	data=YuXi.util.get(url,"null",function(data){
		object=data.object;
		//用data循环添加分类信息
		for(var i=0;i<object.length;i++)
		{
			var html="<option  value="+object[i].id+" >"+object[i].name+"</option>";
			$(".reSearchsort").append(html);
		}
	},function(){
		
	});//请求数据
	
	}
/*function requestSourceSel() {
		var url = "getAllInfomationSource.do"; //渠道地址
		var data = {};
		var object = {};
		data = YuXi.util.get(url, "null", function(data) {
			object = data.object;
			for (var i = 0; i < object.length; i++) {
				var html = "<option value=" + object[i].id + ">" + object[i].name + "</option>";
				$(".reSearchSource ").append(html);
			}

		}, function() {

		});
	}*/